﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.LightSwitch;
namespace LightSwitchApplication
{
    public partial class FishLocation
    {
        partial void TotalRating_Compute(ref double result)
        {
            if (FishLocationComments.Count() == 0)
            {
                result = 3;
                return;
            }
            result = (double)FishLocationComments.Sum(item => item.Rating) / (double)FishLocationComments.Count();
        }

        partial void Name_Compute(ref string result)
        {
            result = string.Format("{0} - {1}", Location.FullName, Fish.Name);

        }
    }
}
